home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STRNCAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  459 b   |  17 lines

  1. /* strncat.c  From TC Bible page 288  Use strncat to concatenate a specified
  2.  number of characters of one string to another. */
  3.  
  4.  #include <stdio.h>
  5.  #include <string.h>
  6.  char result[40] = "a";
  7.  char rest[] = "bcdefghijklmnopqrstuvwxyz";
  8.  unsigned length = sizeof(rest)/sizeof(char);
  9.  main()
  10.  {
  11.     unsigned i;
  12.     for(i = 0;i<length;i++, result[1]='\0')
  13.     {
  14.         strncat(result, rest, i);
  15.         printf("%s\n", result);  /* Show the current result */
  16.     }
  17.  }